/******************************************************************************/
/*  Rfile(RAM) memory map for SmartBUG                                        */
/*                                                                            */
/*  Revision:     1.0                                                         */
/*  Date:         2011/02/02 14:47:33                                         */
/******************************************************************************/

#ifndef __RFILE_MAP_H
#define __RFILE_MAP_H


#include "Rfile\rfile_def.h"


/******************************************************************************/
/*                        SmartBUG RFILE settings                             */
/******************************************************************************/

/* All data are alligned to 16 bits */

#define RFMEM_START          (0)                       // Sys time (uint32)
#define RFMEM_END            (RFILE_RAM_SIZE - 1)      // Sys time (uint32)

/***************************** Space for time *********************************/
#define RFMEM_SYS_TIME       (0)                       // Sys time (uint32)

#define RFMEM_DAY            (RFMEM_SYS_TIME + 4)      // Day (uint16)
#define RFMEM_MONTH          (RFMEM_DAY + 2)           // Month (uint16)
#define RFMEM_YEAR           (RFMEM_MONTH + 2)         // Year(uint16)

#define RFMEM_HOUR           (RFMEM_YEAR + 2)          // Hour (uint16)
#define RFMEM_MIN            (RFMEM_HOUR + 2)          // Min (uint16)
#define RFMEM_SEC            (RFMEM_MIN + 2)           // Sec (uint16)


/***************************** Space for ain **********************************/
#define RFMEM_AIN1           (RFMEM_SEC + 2)           // Ain1 (uint16)
#define RFMEM_AIN2           (RFMEM_AIN1 + 2)          // Ain2 (uint16)
#define RFMEM_AIN3           (RFMEM_AIN2 + 2)          // Ain3 (uint16)


/***************************** Space for temp *********************************/
#define RFMEM_TEMP1          (RFMEM_AIN3 + 2)          // Temp1 (sint16)
#define RFMEM_TEMP2          (RFMEM_TEMP1 + 2)         // Temp2 (sint16)
#define RFMEM_TEMP3          (RFMEM_TEMP2 + 2)         // Temp3 (sint16)
#define RFMEM_TEMP4          (RFMEM_TEMP3 + 2)         // Temp4 (sint16) - internal


/***************************** Space for din **********************************/
#define RFMEM_ROW_DIN1       (RFMEM_TEMP4 + 2)         // Din1 row (uint16)
#define RFMEM_ROW_DIN2       (RFMEM_ROW_DIN1 + 2)      // Din2 row (uint16)
#define RFMEM_ROW_DIN3       (RFMEM_ROW_DIN2 + 2)      // Din3 row (uint16)
#define RFMEM_ROW_DIN4       (RFMEM_ROW_DIN3 + 2)      // Din4 row (uint16)
#define RFMEM_ROW_DIN5       (RFMEM_ROW_DIN4 + 2)      // Din5 row (uint16)
#define RFMEM_ROW_DIN6       (RFMEM_ROW_DIN5 + 2)      // Din6 row (uint16)

#define RFMEM_FILTR_DIN1     (RFMEM_ROW_DIN6 + 2)      // Din1 filtr (uint16)
#define RFMEM_FILTR_DIN2     (RFMEM_FILTR_DIN1 + 2)    // Din2 filtr (uint16)
#define RFMEM_FILTR_DIN3     (RFMEM_FILTR_DIN2 + 2)    // Din3 filtr (uint16)
#define RFMEM_FILTR_DIN4     (RFMEM_FILTR_DIN3 + 2)    // Din4 filtr (uint16)
#define RFMEM_FILTR_DIN5     (RFMEM_FILTR_DIN4 + 2)    // Din5 filtr (uint16)
#define RFMEM_FILTR_DIN6     (RFMEM_FILTR_DIN5 + 2)    // Din6 filtr (uint16)


/***************************** Space for dout *********************************/
#define RFMEM_DOUT1          (RFMEM_FILTR_DIN6 + 2)    // Dout1 (uint16)
#define RFMEM_DOUT2          (RFMEM_DOUT1 + 2)         // Dout2 (uint16)


/******************************** FW revision *********************************/
#define RFMEM_FW_REV         (RFMEM_DOUT2 + 2)         // Fw rev (uint16)


/******************************* Modem status *********************************/
#define RFMEM_MODEM_STATS    (RFMEM_FW_REV + 2)        // Modem status (uint16)


/*************************** Last sending time ********************************/
#define RFMEM_LAST_SND_TIME  (RFMEM_MODEM_STATS + 2)   // Last sending time (uint32)


/*************************** Modbus cmd status ********************************/
#define RFMEM_MB_CMD_STATS   (RFMEM_LAST_SND_TIME + 4) // Modbus stats (8 regs (16 bytes))


/***************************** Space for reserv *******************************/
#define RFMEM_RESERV_ST      (RFMEM_MB_CMD_STATS + 16) // reserv start
#define RFMEM_RESERV_END     (RFMEM_RESERV_ST + 38)    // reserv end (19 regs)


/******************************** User space **********************************/
#define RFMEM_USER_MEM_ST    (RFMEM_RESERV_END)        // user mem
#define RFMEM_USER_MEM_END   (RFILE_RAM_SIZE - 1)      // user mem end (30 regs)



#endif